<!DOCTYPE HTML>
<html>

<head>
	<meta charset="utf-8">
	<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
	<meta name="format-detection" content="telephone=no,email=no,date=no,aItemress=no">
	<title>我的拼团</title>
	<link rel="stylesheet" type="text/css" href="../../../css/base.css" />
	<style type="text/css">
		body {
			background-color: #F0F1F2;
		}

		.item-wraper {
			width: 100%;
			background: #ffffff;
			padding: 0 0.15rem;
			margin-bottom: 0.1rem;
		}
		.group-wraper {
			margin-top: 0.1rem;
		}

		.item-wraper img {
			width: 0.76rem;
			height: 0.76rem;
			margin-right: 0.1rem;
		}

		.item-wraper .item .item-top {
			display: flex;
			border-bottom: 1px solid #e6e6e6;
			padding: 0.15rem 0;
		}

		.item-wraper .item .item-top .right-cont {
			width: 100%;
		}

		.item-wraper .item .item-top .right-cont .title {
			width: 100%;
			font-size: 0.15rem;
			font-family: PingFangSC-Medium, PingFang SC;
			font-weight: 500;
			color: rgba(77, 77, 77, 1);
			line-height: 0.21rem;
			margin-bottom: 0.34rem;
			display: -webkit-box;
			-webkit-box-orient: vertical;
			-webkit-line-clamp: 1;
			overflow: hidden;
		}

		.bottom {
			display: flex;
			justify-content: space-between;
			align-items: center;
		}

		.bottom .left-price {
			display: flex;
			align-items: center;
		}

		.bottom .left-price .current-price {
			font-size: 0.15rem;
			font-family: PingFangSC-Medium, PingFang SC;
			font-weight: 500;
			color: rgba(77, 77, 77, 1);
			line-height: 0.21rem;
			margin-right: 0.08rem;
		}

		.bottom .left-price .original-price {
			font-size: 0.12rem;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: rgba(153, 153, 153, 1);
			line-height: 0.17rem;
			margin-top: 0.03rem;
		}

		.bottom .right-num {
			font-size: 0.14rem;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: rgba(0, 90, 147, 1);
			line-height: 0.2rem;
		}

		.item-bottom {
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 0.1rem 0;
		}

		.item-bottom .status {
			font-size: 0.13rem;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: rgba(247, 48, 36, 1);
			line-height: 0.18rem;
		}

		.right-btn {
			display: flex;
		}

		.right-btn .left-btn {
			margin-right: 0.15rem;
			padding: 0.05rem 0.16rem;
			border-radius: 0.16rem;
			border:1px solid rgba(153,153,153,0.4);
			font-size: 0.13rem;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: rgba(77, 77, 77, 1);
			line-height: 0.18rem;
		}

		.right-btn .right-btn {
			padding: 0.05rem 0.16rem;
			border-radius: 0.16rem;
			font-size: 0.13rem;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: rgba(255, 255, 255, 1);
			line-height: 0.18rem;
			background: #005a93;
		}
	</style>
</head>

<body>
	<div id="app" v-cloak="">
		<!--  -->
		<div class="group-wraper">


			<div class="item-wraper" v-for="vo in info">
				<!-- 拼团列表项 -->
				<div class="item">
					<div class="item-top">
						<img :src="vo.good.img"  />
						<div class="right-cont">
							<div class="title">	{{vo.good.title}}</div>
							<div class="bottom">
								<div class="left-price">
									<div class="current-price">￥{{vo.good.current_price}}</div>
									<div class="original-price">
										<del>￥{{vo.good.cost_price}}</del>
									</div>
								</div>
								<div class="right-num">{{vo.tuan_uid_num}}人成团</div>
							</div>
						</div>
					</div>

					<div class="item-bottom">
						<div class="status">
							<span v-if="vo.status=='0'">全部</span>
					    	<span v-if="vo.status=='10'">进行中</span>
					    	<span v-if="vo.status=='20'">成功</span>
					    	<span v-if="vo.status=='30'">失败</span>
						</div>
						<div class="right-btn">
							<div class="left-btn" @click="openWin_goods_detail(vo.tuan_uid_id)">拼团详情</div>
							<div class="right-btn" @click="sharepage(vo.good_id,vo.good.title,vo.good.cover)">邀请好友</div>
						</div>
					</div>
				</div>
				<!--  -->
			</div>

				<!-- 缺省页面 -->
				<div class="aui-text-center"  v-if="info.length < 1" style="margin-top: 1.04rem;" tapmode >
					<img src="../../../image/bg/bg-nonecar.png" style="width:1.51rem;margin-left:50%;transform:translateX(-50%);" />
					<div style="font-size:0.14rem;font-family:PingFangSC-Regular;font-weight:400;color:#B3B3B3;margin-top:0.27rem;width:100%; text-align: center;">
					   暂无数据
					</div>
				</div>
		</div>
	</div>
</body>
<script type="text/javascript" src="../../../script/api.js"></script>
<script type="text/javascript" src="../../../script/vue.js"></script>
<script type="text/javascript" src="../../../script/common.js"></script>
<script type="text/javascript" src="../../../script/aui-dialog.js"></script>
<script type="text/javascript" src="../script/swiper.min.js"></script>
<script type="text/javascript" src="../script/aui-actionsheet.js"></script>
<script>	var vm = new Vue({
		el: '#app',
		data: {
			index: 'all',
			info: [],
			page: 1,
			loadmore: true
		},
		methods: {
			get_list: function() {
				get_data('api/Tuan/myTuanList', {
					token: $api.getStorage('token'),
					status: vm.index
				}, function(ret) {
					alert(JSON.stringify(ret))
					console.log(JSON.stringify(ret))
					if (ret.status) {
						vm.info = ret.data
							//							if(ret.data.length < 20) {
							//								vm.loadmore = false
							//							}
							//							ret.data.forEach(function(el) {
							//								vm.info.push(el)
							//							})
					}
				})
			},
			price_format: function(type, price) {
				var price = (price / 100).toFixed(2);
				var status = (price + '').indexOf('.')
				if (status == '-1') {
					if (type == 'yuan') {
						return price;
					}
					if (type == 'fen') {
						return '00';
					}
				}
				var price_array = (price + '').split('.')
				if (type == 'yuan') {
					return price_array[0];
				}
				if (type == 'fen') {
					var price_fen = price_array[1].length < 2 ? price_array[1] + '0' : price_array[1];
					return price_fen;
				}
			}

		}
	})
	apiready = function() {

		vm.get_list()
		// fnInitPullRefresh(function() {
		// 		vm.page = 1;
		// 		vm.loadmore = true
		// 		vm.info = [];
		// 		vm.get_list()
		// 	})

		fnInitPullRefresh(function() {
			vm.get_list();
			api.refreshHeaderLoadDone();

		})
			// 新版刷新
		// refresh_new(function() {
		// 	setTimeout(function() {
		// 		vm.page = 1;
		// 		vm.loadmore = true
		// 		vm.info = [];
		// 		vm.get_list()
		// 		api.refreshHeaderLoadDone()
		// 	}, 1000)
		// })
		// fnInitScrollToBottom(function() {
		// 		if (vm.loadmore) {
		// 			vm.page++;
		// 			vm.get_list()
		// 		}
		// 	})
			//首页顶部最新按钮跟点赞数按钮点击时触发
		add_event('pintuan_index', function(ret) {
			vm.index = ret.index
			vm.info = [];
			vm.page = 1;
			vm.loadmore = true
			vm.get_list()
		})
	};

	function tapindex(index) {
		if (vm.index != index) {
			vm.index = index
			vm.get_list()
		}
	}
	var timeOutEvent = 0;

	function gtouchstart(index) {
		api.addEventListener({
			name: 'longpress'
		}, function(ret, err) {
			longPress(index);
		});
		return false;
	};

	function gtouchend() {
		clearTimeout(timeOutEvent);
		if (timeOutEvent != 0) {
			//这里写要执行的内容（尤如onclick事件）
			//				console.log("你这是点击，不是长按");
		}
		return false;
	};

	function gtouchmove() {
		clearTimeout(timeOutEvent);
		timeOutEvent = 0;
		console.log("你移动了啊");
	};


	function longPress(index) {
		timeOutEvent = 0;
		del_item(index)
	}

	// var timeOutEvent = 0;
	//
	// function gtouchstart(index) {
	// 	timeOutEvent = setTimeout(function() {
	// 		longPress(index)
	// 	}, 500);
	// 	return false;
	// };
	//
	// function gtouchend() {
	// 	clearTimeout(timeOutEvent);
	// 	if (timeOutEvent != 0) {
	// 		//这里写要执行的内容（尤如onclick事件）
	// 		//			console.log("你这是点击，不是长按");
	// 	}
	// 	return false;
	// };
	//
	// function gtouchmove() {
	// 	clearTimeout(timeOutEvent);
	// 	timeOutEvent = 0;
	// };
	//
	// function longPress(index) {
	// 	timeOutEvent = 0;
	// 	//执行长按要执行的内容，如弹出菜单
	// 	del_item(index)
	// }

	function del_item(id) {
		var dialogBox = api.require('dialogBox');
		dialogBox.alert({
			texts: {
				title: '提示',
				content: '确定要删除这条拼团信息吗？',
				leftBtnTitle: '取消',
				rightBtnTitle: '确认'
			},
			styles: {
				bg: '#fff',
				w: 295,
				corner: 10,
				title: {
					marginT: 20,
					titleSize: 17,
					titleColor: '#444444'
				},
				content: {
					marginT: 18,
					marginB: 30,
					color: '#444444',
					size: 17
				},
				left: {
					marginB: 0,
					marginL: 0,
					w: 147.5,
					h: 55,
					corner: 10,
					// bg: 'widget://image/ico/ico_btn_left_bg.png',
					bg: "#fff",
					color: '#999999',
					size: 16
				},
				right: {
					marginB: 0,
					marginL: 0,
					w: 147.5,
					h: 55,
					corner: 10,
					bg: '#fff',
					color: '#005A93',
					size: 16
				},
				horizontalLine: {
					color: '#EEEEEE',
					height: 1
				},
				verticalLine:{
	        color:'#EEEEEE', //（可选项）字符串类型；左右按钮中间竖线的颜色，支持rgb、rgba、#；默认：'rgba(245,245,245,0)'
		      width:1                 //（可选项）数字类型；左右边按钮竖线的高度；默认：0
		    }
			}
		}, function(ret) {
			if (ret.eventType == 'left') {
				var dialogBox = api.require('dialogBox');
				dialogBox.close({
					dialogName: 'alert'
				});
			} else if (ret.eventType == 'right') {
							get_data('api/tuan/delMyTuan', {
								token: $api.getStorage('token'),
								id: id
							}, function(ret) {
								if (ret.status) {
									toast('删除成功')
									vm.get_list()
								}
							})
				var dialogBox = api.require('dialogBox');
				dialogBox.close({
					dialogName: 'alert'
				});
			}
		});
		// var dialog = new auiDialog();
		// dialog.alert({
		// 	title: "提示",
		// 	msg: '确定要删除这条拼团信息吗？',
		// 	buttons: ['取消', '确定']
		// }, function(ret) {
		// 	if (ret) {
		// 		if (ret.buttonIndex == '2') {
		// 			get_data('api/tuan/delMyTuan', {
		// 				token: $api.getStorage('token'),
		// 				id: id
		// 			}, function(ret) {
		// 				if (ret.status) {
		// 					toast('删除成功')
		// 					vm.get_list()
		// 				}
		// 			})
		// 		}
		// 	}
		// })
	}


	function sharepage(id, title, share_pic) {
		if (!$api.getStorage('token')) {
			openWin_login()
			return;
		}
		var dialogBox = api.require('dialogBox');
		dialogBox.actionMenu({
			animation: true,
			isCuttingLine: false,
			tapClose: true,
			rect: {
				h: 197
			},
			texts: {
				cancel: '取消'
			},
			items: [{
				text: '朋友圈',
				icon: 'widget://image/icon/wechatSpace.png'
			}, {
				text: '微信好友',
				icon: 'widget://image/icon/friends.png'
			}],
			styles: {
				bg: '#F6F6F6',
				corner: 6,
				column: 3,
				itemText: {
					color: '#333333',
					size: 15,
					marginT: 5
				},
				itemIcon: {
					size: 60
				},
				cancel: {
					bg: '#fff',
					color: '#666666',
					h: 55,
					size: 15,

				}
			}
		}, function(ret) {
			if (ret) {
				if (ret.eventType == "cancel") {
					dialogBox.close({
						dialogName: 'actionMenu'
					});
				}
				if (ret.index == "0") {
					shareTowx('timeline', id, title, share_pic)
					dialogBox.close({
						dialogName: 'actionMenu'
					});
				}
				if (ret.index == "1") {
					shareTowx('session', id, title, share_pic)
					dialogBox.close({
						dialogName: 'actionMenu'
					});
				}
				if (ret.index == "2") {
					shareTowb(id, title, share_pic)
					dialogBox.close({
						dialogName: 'actionMenu'
					});
				}
			}

		});
	}

	// 分享到微信朋友圈
	function shareTowx(type, id, title, share_pic) {
		var contentUrl = 'http://zm.zonmay.com/wap/share/goods/id/' + id + '.html'
		var title = title
		var wx = api.require('wxPlus');
		wx.isInstalled(function(ret, err) {
			if (ret.installed) {} else {
				toast('当前设备未安装微信客户端');
				return;
			}
		});
		wx.shareWebpage({
			scene: type,
			title: title,
			description: title,
			contentUrl: contentUrl,
			thumb: share_pic
		}, function(ret, err) {
			if (ret.status) {
				toast('分享成功');
				get_data('api/user/shareTakeGold', {
					token: $api.getStorage('token')
				}, function(ret) {
					if (ret.status) {
						console.log(JSON.stringify(ret.data))
						vm.share_gold = ret.data.gold
						vm.share_show = true
						setTimeout(function() {
							vm.share_show = false
						}, 3000)
					}
				})
			} else {
				if (err.code == '2') {
					toast('取消分享');
				}
				console.log(err.code);
			}
		});
	}

	// 查看分享链接中的内容
	function shareTowb(id, title, share_pic) {
		var contentUrl = 'http://zm.zonmay.com/wap/share/goods/id/' + id + '.html'
		var title = title
		var weibo = api.require('weiboPlus');
		weibo.shareWebPage({
			text: title + '。详情点击链接查看',
			title: title,
			description: title,
			thumb: share_pic,
			contentUrl: contentUrl
		}, function(ret, err) {
			console.log(JSON.stringify(ret))
			if (ret.status) {
				toast('分享成功');
				get_data('api/user/shareTakeGold', {
					token: $api.getStorage('token')
				}, function(ret) {
					if (ret.status) {
						vm.share_gold = ret.data.gold
						vm.share_show = true
						setTimeout(function() {
							vm.share_show = false
						}, 3000)
					}
				})
			} else {
				if (err.code == '1') {
					toast('取消分享');
				}
				console.log(JSON.stringify(err))
			}
		});
	}
	function isOnLineStatus(callback) {
		var s = api.connectionType;
		var count = 0;
		s = s.toLowerCase();
		if ((s.indexOf('wifi') != -1) || (s.indexOf('3g') != -1) || (s.indexOf('4g') != -1) || (s.indexOf('2g') != -1)) {
			//callback(true, s);
			vm.isnetwork = true

		} else {
			vm.isnetwork = false
		}
	}
	function refresh_network() {
		// vm.get_list()
		var flag = true;
		function once() {
			if (flag) {
				window.location.reload()
				flag = false;
			} else {
				return;
			}
		}
		once();
		send_event('reflesh_network');
	}
</script>

</html>
